// 嵌入C测试f
#include <stdint.h>
#define NPU ((volatile uint32_t*)0x10000000)

void npu_dotp(int16_t *a, int16_t *b, int len, int32_t *out) {
  NPU[4] = (uint32_t)a;    // SRC_A
  NPU[5] = (uint32_t)b;    // SRC_B
  NPU[6] = (uint32_t)out;  // DST
  NPU[0] = (len << 16) | 1;
  while (!(NPU[0] & 2));
}

int main() {
  int16_t a[4] = {1, 2, -3, 4};
  int16_t b[4] = {5, 6,  7, 8};
  int32_t result;
  npu_dotp(a, b, 4, &result);
  // 期望: 1*5 + 2*6 + (-3)*7 + 4*8 = 5+12-21+32 = 28
  return (result == 28) ? 0 : 1;
}